package com.hc.componentspringboot.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 数据源配置类
 * 如果改了默认的DataSource类型则需要此配置类,Spring容器将自动扫描和加载此类
 */

@Configuration
public class DataSourceConfig {

    @ConfigurationProperties(prefix = "spring.datasource")
    @Bean //将对象交给Spring容器管理
    public DataSource getDataSource(){
        return new DruidDataSource();
    }
}
